package com.yourenbang.lingyun.transaction.util;

import com.yourenbang.lingyun.core.support.WafRequestWrapper;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public final class HttpHolderUtil {
	/**
	 * 获取当前HttpServletResponse
	 */
	public static HttpServletResponse getResponse() {
		HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
				.getResponse();
		return response;
	}
	/**
	 * 获取当前HttpServletRequest
	 */
	public static HttpServletRequest getRequest() {
		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
				.getRequest();
		return new WafRequestWrapper(request);
	}
	/**
	 * 获取当前登录用户id
	 */
	public static String getUserId(){
		return (String) getRequest().getSession().getAttribute("userId");
	}

}
